<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-商品列表"> </@frame.head>
<script type="text/javascript">
var path="${contextPath}";
</script>
<script type="text/javascript" src="${contextPath}/resources/static/ueditor/utf8-jsp/ckeditor.js"></script>
<script type="text/javascript" src="${contextPath}/resources/static/ueditor/utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${contextPath}/resources/static/ueditor/utf8-jsp/ueditor.all.js"></script>
<script type="text/javascript" src="${contextPath}/resources/static/ueditor/utf8-jsp/index/index.js"></script>
<script type="text/javascript" src="${contextPath}/resources/static/ueditor/utf8-jsp/lang/zh-cn/zh-cn.js"></script>
<div class="page-container">
	<form action="${contextPath}/finetTalk/backstagespeak_update" method="post"
		class="form form-horizontal" id="jvForm" enctype="multipart/form-data">
  <input type="hidden" name="finetTalkid" id="id" value="${finetTalk.finetTalkid?c}">
		<div id="file_size"
			style="width: 400px; border-bottom: 1px solid #C0C0C0;"></div>
		<br />

		<div>
        <tr>
            <td width="20%">
                <span>*</span>
                上传图片(90x150尺寸):</td>
                <td width="80%">
                 注:该尺寸图片必须为90x150。
                </td>
        </tr>

                <tr>
                 <td width="20%"></td>
                    <td width="80%">
                        <img width="100" height="100" id="allUrl" src="${webPath}/finetTalk/${finetTalk.imge}" />
                        <!-- 在选择图片的时候添加事件，触发Ajax异步上传 -->
                        <input name='pic' type="file" id="imge"
					onchange="imgee(this)" />
                     </td>
                </tr>
        </div>


		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				课程标题：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" class="input-text" placeholder=""
					id="title" name="title" value="${finetTalk.title}">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				艺术专业：</label>
			<div class="formControls col-xs-6 col-sm-6">
			<div class="radio-box">
					<input type="radio"  name="navigation" value="1"
						 <#if finetTalk.navigation==1>	checked</#if>>
					<label for="radio-2">推荐</label>
				</div>
				<div class="radio-box">
					<input type="radio"  name="navigation" value="5"
					 <#if finetTalk.navigation==2>	checked</#if>>
					<label for="radio-2">速写</label>
				</div>
				<div class="radio-box">
					<input type="radio"  name="navigation" value="3"
					 <#if finetTalk.navigation==3>	checked</#if>>
					<label for="radio-2">素描</label>
				</div>
				<div class="radio-box">
					<input type="radio"  name="navigation" value="4"
					 <#if finetTalk.navigation==4>	checked</#if>>
					<label for="radio-2">色彩</label>
				</div>
				<!-- <div class="radio-box">
					<input type="radio"  name="courseTypeOne" value="2"
					<#if courses.courseTypeOneId==2>	checked</#if>>
					<label for="radio-2">色彩</label>
				</div>
				
				<div class="radio-box">
					<input type="radio"  name="courseTypeOne" value="3"
					<#if courses.courseTypeOneId==3>	checked</#if>>
					<label for="radio-2">素描</label>
				</div>
				
				<div class="radio-box">
					<input type="radio"  name="courseTypeOne" value="4"
					<#if courses.courseTypeOneId==4>	checked</#if>>
					<label for="radio-2">速写</label>
				</div> -->
			</div>
		</div>
		<div class="mt-20 skin-minimal">
				<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				是否置顶：</label>
				<div class="radio-box">
					<input onclick="show(1)" type="radio" id="isPy-1" name="topping"
					value="1" <#if finetTalk.topping==1> checked </#if> >
					<label for="radio-2" >是</label>
				</div>
				
			
				<div class="radio-box">
					<input onclick="show(2)" type=radio id="isPay-2" name="topping"
					value="2" <#if finetTalk.topping==2> checked </#if> >
					<label for="radio-1" >否</label>
				</div>
				</div>
			<div id="paixu" class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				排序：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<input type="text" placeholder=""
					id="serialNumber" name="serialNumber" value="${finetTalk.serialNumber}">
			</div>
		</div>
			
				
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">
				<span class="c-red">*</span>
				课程简介：</label>
			<div class="formControls col-xs-6 col-sm-6">
				<textarea cols="80" id="editor" name="content">${finetTalk.content}</textarea> 
				
				
			</div>
		</div>
		<div class="row cl">
			<div class="col-9 col-offset-2">
<input class="btn btn-primary radius" onclick="submitFinetTalk()"
						value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
			</div>
	
	</form>
</div>
<@frame.end "default">
</@frame.end>


<script type="text/javascript">
	function getObjectURL(file) {
		var url = null;
		if (window.createObjectURL != undefined) {
			url = window.createObjectURL(file)
		} else if (window.URL != undefined) {
			url = window.URL.createObjectURL(file)
		} else if (window.webkitURL != undefined) {
			url = window.webkitURL.createObjectURL(file)
		}
		return url
	};

	function imgee(obj) {

		// 上传设置
		var imgObj = getObjectURL(obj.files[0]);//获取图片
		$("#allUrl").attr("src", imgObj);

	}

	function submitFinetTalk() {
		var patternNum=/^[0-9]*$/;
		var title=$("#title").val();
		var serialNumber=$("#serialNumber").val();
		/* if(imag=="" || imag.length==0){
			layer.alert("请选择要上传的图片！");
			return false;
		} */
		if(title=="" || title.length==0){
			layer.alert("标题不能为空！");
			return false;
		}
		if (!patternNum.test(serialNumber)) {
			layer.alert("序号只能填写数字！");
			return false;
		}
		$("#jvForm").ajaxSubmit({
			dataType : 'text',
			success : function(message) {

				if (message == "200") {
					layer.msg('修改成功!', {
						icon : 1,
						time : 1000
					}, function() {
						parent.window.location.reload();
					});
				} else if (message.code == "500") {
					layer.alert(message.message);
				} else if (message == "505") {
					layer.alert("只有老师和机构管理员才能操作!");
				} else if (message == "500") {
					layer.alert(message.message);
					parent.window.location.reload();
				} else {
					layer.alert(message.message);
					parent.window.location.reload();
				}
			},
			error : function() {
				layer.msg('操作失败!', {
					icon : 5,
					time : 1000
				});
			},
			complete : function(XMLHttpRequest, textStatus) {

			}
		});
	}
	
	function show(type) {
		if(type==1){
			$("#paixu").show();
		}else{
			$("#paixu").hide();
			var inputObj = document.getElementById('serialNumber');
			if(inputObj.value != null){
				inputObj.value='';
			}
			
		}
	}
	 //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');


    function isFocus(e){
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }
    function setblur(e){
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }
    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }
    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }
    function getAllHtml() {
        alert(UE.getEditor('editor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
        UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UE.getEditor('editor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UE.getEditor('editor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UE.getEditor('editor').selection.getRange();
        range.select();
        var txt = UE.getEditor('editor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UE.getEditor('editor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UE.getEditor('editor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UE.getEditor('editor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UE.getEditor('editor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
        }
    }

    function getLocalData () {
        alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
    }

    function clearLocalData () {
        UE.getEditor('editor').execCommand( "clearlocaldata" );
        alert("已清空草稿箱")
    }
</script>
</body>
</html>